using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;

public class PlayerPrefsEx : MonoBehaviour
{
    [DllImport("__Internal")]
    public static extern void SetLocalStorage(string key, string value);

    [DllImport("__Internal")]
    static extern string GetLocalStorage(string key);

    [DllImport("__Internal")]
    public static extern void RemoveLocalStorage(string key);

    // Helper method to call RemoveLocalStorage  
    public static void RemoveFromLocalStorage(string key)
    {
        RemoveLocalStorage(key);
    }

    /*******************************************************************/

    private string key="testkey";
    private string va="hhfhadsfa";

    private void OnGUI()
    {
        GUILayout.Label("key,value");
        key = GUILayout.TextField(key);
        va = GUILayout.TextField(va, GUILayout.Width(500), GUILayout.Height(200));
        if (GUILayout.Button("Save"))
        {
            SetLocalStorage(key, va);
        }

        if (GUILayout.Button("read"))
        {
            var result = GetLocalStorage(key);
            Debug.Log($"read==> key={key}, result = {result}");
        }
    }
}